package main

import (
	"log"
	"os"
	"text/template"
)

func main() {

	t := template.Must(template.ParseGlob("./views/*.tpl"))

	//定义用户类型
	type User struct {
		Id int
		UserName string
	}

	//模版参数类型
	type Data struct {
		User User
	}

	//定义user
	user := User{Id:1001, UserName:"李大成"}

	//初始化模版参数, 假设我们传入的模版参数是data
	data := Data{}
	data.User = user

	err := t.ExecuteTemplate(os.Stdout, "struct", data)
	if err != nil {
		log.Println("executing template:", err)
	}




}
